<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function sayHi() {
            console.log("sayHi");
        }

        var obj = {
            name: "jack",
            age: 23,
            sayHello: function () {
                console.log("sayHello");
            }
        }

        var obj2 = new Object();
        obj2.sayOk = function () {
            console.log("sayOk");
        }
        // 调用方法
        obj.sayHello();
        obj2.sayOk();
        //调用函数
        sayHi();
        console.log("================================");
        //枚举对象中的属性
        for (const key in obj) { // key: 属性名  obj[key] : 属性值
            if (obj.hasOwnProperty(key)) {
                // obj.key  ： 点的方式不能使用变量
                const element = obj[key];
                console.log(element);
            }
        }
    </script>
</body>

</html>